package com.shd.edanpei.bean;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

import com.shd.edanpei.enums.GenderEnum;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by mc on 2018/9/28.
 * yang-wen-wen
 */

public class CustomerInfoBean implements Parcelable {
    /**
     * customerId : 56
     * customerName : 虎牢关战神
     * birthday : 2018-09-23
     * sex : 0
     * idCardNo : 853828328343732283
     * mobile : 15046506540
     * bankCardNo : 543832482786505406540
     * isMarrage : false
     * address : 浙江省 杭州市 滨江区
     * detailAddress : 杭州西湖
     * income : 3K以下
     * industry : 技术
     * spouseName :
     * spouseMobile :
     */

    private int customerId;
    private String customerName;
    private String birthday;
    private int sex;
    private String idCardNo;
    private String customerMobile;
    private String bankCardNo;
    private boolean isMarrage;
    private String address;
    private String detailAddress;
    private String income;
    private String industry;
    private String spouseName;
    private String spouseMobile;

    protected CustomerInfoBean(Parcel in) {
        customerId = in.readInt();
        customerName = in.readString();
        birthday = in.readString();
        sex = in.readInt();
        idCardNo = in.readString();
        customerMobile = in.readString();
        bankCardNo = in.readString();
        isMarrage = in.readByte() != 0;
        address = in.readString();
        detailAddress = in.readString();
        income = in.readString();
        industry = in.readString();
        spouseName = in.readString();
        spouseMobile = in.readString();
    }

    public static final Creator<CustomerInfoBean> CREATOR = new Creator<CustomerInfoBean>() {
        @Override
        public CustomerInfoBean createFromParcel(Parcel in) {
            return new CustomerInfoBean(in);
        }

        @Override
        public CustomerInfoBean[] newArray(int size) {
            return new CustomerInfoBean[size];
        }
    };

    public int getCustomerId() {
        return customerId;
    }

    public String getCustomerName() {
        return customerName;
    }

    public String getCustomerName2() {
        return TextUtils.isEmpty(customerName) ? "" : customerName.substring(0, 1) + "**";
    }

    public String getBirthday() {
        return birthday;
    }

    public String getBirthday2() {
        return "********";
    }

    public int getSex() {
        return sex;
    }

    public String getGender() {
        return GenderEnum.getGender(sex);
    }

    public String getIdCardNo() {
        return idCardNo;
    }

    public String getMobile() {
        return customerMobile;
    }
//
//    public String getBankCardNo() {
//        return bankCardNo;
//    }

    public boolean isMarrage() {
        return isMarrage;
    }

    public String marrageStatus() {
        return isMarrage ? "已婚" : "未婚";
    }

    public String getAddress() {
        return address;
    }

    public String getDetailAddress() {
        return detailAddress;
    }

    public String getIncome() {
        return income;
    }

    public String getIndustry() {
        return industry;
    }

    public String getSpouseName() {
        return spouseName;
    }

    public String getSpouseName2() {
        return !TextUtils.isEmpty(spouseName) ? spouseName.substring(0, 1) + "**" : "***";
    }

    public String getSpouseMobile(boolean b) {
        return b ? (spouseMobile.length() != 11 ? spouseMobile : spouseMobile.substring(0, 3) + "****" + spouseMobile.substring(7, spouseMobile.length())) : spouseMobile;
    }


    public List<DataBean> getDataList() {
        List<DataBean> list = new ArrayList<>();
        list.add(new DataBean("姓名", getCustomerName()));
        list.add(new DataBean("性别", GenderEnum.getGender(sex)));
        list.add(new DataBean("出生日期", getBirthday()));
        list.add(new DataBean("身份证号", getIdCardNo()));
        list.add(new DataBean("联系方式", getMobile()));
//        list.add(new DataBean("银行卡号", getBankCardNo()));
        list.add(new DataBean("婚姻状况", isMarrage() ? "已婚" : "未婚"));
        if (isMarrage) {
            list.add(new DataBean("配偶姓名", getSpouseName()));
            list.add(new DataBean("配偶联系方式", getSpouseMobile(false)));
        }

        list.add(new DataBean("当前收入", getIncome()));
        list.add(new DataBean("行业", getIndustry()));
        list.add(new DataBean("常住地址", getAddress()));
        list.add(new DataBean("详细地址", getDetailAddress()));
        return list;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(customerId);
        dest.writeString(customerName);
        dest.writeString(birthday);
        dest.writeInt(sex);
        dest.writeString(idCardNo);
        dest.writeString(customerMobile);
        dest.writeString(bankCardNo);
        dest.writeByte((byte) (isMarrage ? 1 : 0));
        dest.writeString(address);
        dest.writeString(detailAddress);
        dest.writeString(income);
        dest.writeString(industry);
        dest.writeString(spouseName);
        dest.writeString(spouseMobile);
    }
}
